package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.model.KaoQin;
import com.zr.service.KaoQinService;

public class AddKaoQinController extends HttpServlet{
	KaoQinService kqs=new KaoQinService();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doGet(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		//接收到值
		String wname=req.getParameter("wname");
		String wsex =req.getParameter("wsex");
		int vacate_day= Integer.parseInt(req.getParameter("vacate_day"));
		String start_time=req.getParameter("start_time");
		String end_time=req.getParameter("end_time");
		//将值传入service，得到反馈结果
		int result=kqs.addKaoQin(wname, wsex, vacate_day, start_time, end_time);
		//将反馈的结果写会页面
	    PrintWriter  pw = resp.getWriter();
	    pw.write(String.valueOf(result));
	}
}
